﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MediSIIM.BaseBiz;
using System.Configuration;
using System.IO;
using System.Windows.Forms;
using SIIMWeb.YIBAO;

namespace TradeTest
{
    public class CallParam
    {
        public string TradeName { get; set; }
        public object this[int index] { get { return Values[index]; } set { Values.Add(value); } }
        public string YLBXMC { get; set; }
        public List<object> Values { get; set; }
        public string BizDll { get; set; }
        public string ClassName { get; set; }

        public CallParam(string ylbxid, string tradeName)
        {
            YLBXMC = ylbxid;
            Values = new List<object>();
            TradeName = tradeName;
            GetAssemblyFile0();
        }

        void GetAssemblyFile0()
        {
            string clientVersion = "v2_001";
            string path = Application.StartupPath + "\\" + YLBXMC;
            string fileFilter = "MediSIIM.BizComponent." + YLBXMC + "." + clientVersion + "_???.dll";
            DirectoryInfo dir = new DirectoryInfo(path);
            int maxServerVersion = 0;
            string maxVersionFileName = string.Empty;
            foreach (var fileInfo in dir.GetFiles(fileFilter))
            {
                string strServerVersion = fileInfo.Name.Substring(fileInfo.Name.Length - 7, 3);
                int serverVersion = 0;
                if (int.TryParse(strServerVersion, out serverVersion) && serverVersion > maxServerVersion)
                {
                    maxVersionFileName = fileInfo.Name;
                    maxServerVersion = serverVersion;
                }
            }

            BizDll = path + "\\" + maxVersionFileName;
            ClassName = "MediSIIM.BizComponent." + YLBXMC + "." + TradeName;
        }
    }
}